package com.kongzue.baseokhttp.util;

import java.util.Objects;

/**
 * RequestInfo
 *
 * @author: Kongzue
 * @github: https://github.com/kongzue/
 * @homepage: http://kongzue.com/
 * @mail: myzcxhh@live.cn
 * @createTime: 2020/11/4 12:48
 */
public class RequestInfo {

    private String url;

    private String parameter;

    /**
     * RequestInfo
     *
     * @param url       url
     * @param parameter parameter
     */
    public RequestInfo(String url, String parameter) {
        this.url = url;
        this.parameter = parameter;
    }

    /**
     * RequestInfo
     *
     * @param url       url
     * @param parameter parameter
     */
    public RequestInfo(String url, Parameter parameter) {
        this.url = url;
        this.parameter = parameter.toParameterString();
    }

    /**
     * getUrl
     *
     * @return String
     */
    public String getUrl() {
        return url;
    }

    /**
     * setUrl
     *
     * @param url url
     * @return RequestInfo
     */
    public RequestInfo setUrl(String url) {
        this.url = url;
        return this;
    }

    /**
     * getParameter
     *
     * @return String
     */
    public String getParameter() {
        return parameter;
    }

    /**
     * RequestInfo
     *
     * @param parameter parameter
     * @return RequestInfo
     */
    public RequestInfo setParameter(String parameter) {
        this.parameter = parameter;
        return this;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        RequestInfo that = (RequestInfo) o;
        return Objects.equals(url, that.url) &&
                Objects.equals(parameter, that.parameter);
    }

    @Override
    public int hashCode() {
        return Objects.hash(url, parameter);
    }

    @Override
    public String toString() {
        return "RequestInfo{"
                +
                "url='" + url
                + '\''
                +
                ", parameter='"
                + parameter + '\''
                +
                '}';
    }
}
